package com.example.testapplication.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.example.testapplication.R;
import com.example.testapplication.adapter.CartMainAdapter;
import com.example.testapplication.adapter.OrderFragmentAdapter;
import com.example.testapplication.adapter.ShoppingFragmentAdapter;
import com.example.testapplication.api.Api;
import com.example.testapplication.api.ApiConfig;
import com.example.testapplication.api.CallBack;
import com.example.testapplication.entity.Result;
import com.flyco.tablayout.SlidingTabLayout;
import com.google.gson.Gson;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

public class OrderFragment extends BaseFragment{
    private ArrayList<Fragment> fragments = new ArrayList<>();
    private final String[] mTitles = {"全部","已付款","未付款"};
    private ViewPager viewPager;
    private SlidingTabLayout slidingTabLayout;


    public static OrderFragment newInstance() {
        OrderFragment fragment = new OrderFragment();
        return fragment;
    }

    @Override
    protected int initLayout() {
        return R.layout.fragment_order;
    }

    @Override
    protected void initView() {
        viewPager = mRootView.findViewById(R.id.fixedViewPagerOrder);
        slidingTabLayout = mRootView.findViewById(R.id.slidingTabLayoutOrder);
    }

    @Override
    protected void initData() {
        for(int i=0;i<mTitles.length;i++){
            fragments.add(OrderMsgFragment.newInstance(i));
        }
        viewPager.setOffscreenPageLimit(fragments.size());
        viewPager.setAdapter(new OrderFragmentAdapter(getFragmentManager(),mTitles,fragments));
        slidingTabLayout.setViewPager(viewPager);
    }

}